package application.view 
{
	import application.ApplicationFacade;
	import application.model.VO.GroupVO;
	import application.model.VO.PhotoViewVO;
	import application.view.viewComponent.PhotoView;
	import flash.events.Event;
	import ginger.events.DataEvent;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Ning
	 */
	public class PhotoViewMediator extends Mediator implements IMediator 
	{
		public static const NAME:String = 'PhotoMediator';
		public function PhotoViewMediator(viewComponent:PhotoView) 
		{
			super(NAME, viewComponent);
			photoView.addEventListener(PhotoView.EXIT, onExit);
		}
		private function get photoView():PhotoView {
			return viewComponent as PhotoView;
		}
		override public function handleNotification(notification:INotification):void 
		{
			switch(notification.getName())
			{
				case ApplicationFacade.UPDATE_PIC_AREA_DATA:
				photoView.updateData(notification.getBody() as Array);
				break;
				case ApplicationFacade.SHOW_PHOTO_VIEW:
				photoView.showPhotoByIndex(int(notification.getBody()));
				break;
				case ApplicationFacade.UPDATE_PHOTO_VIEW_CONFIG:
				photoView.updateConfig(notification.getBody() as PhotoViewVO);
				break;
			}
		}
		override public function listNotificationInterests():Array 
		{
			return [ApplicationFacade.UPDATE_PIC_AREA_DATA,ApplicationFacade.SHOW_PHOTO_VIEW,ApplicationFacade.UPDATE_PHOTO_VIEW_CONFIG];
		}
		private function onExit(evt:Event):void
		{
			sendNotification(ApplicationFacade.SHOW_PHOTO_AREA);
		}
	}
}